<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
    <#include "/common/elibs.html">
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
</head>
<body>
<div class="x-body">
    <form class="layui-form">
        <input type="hidden" name="idxProAdmin" id="idxProAdmin" value="${id}"/>
        <input type="hidden" name="idProSceneInvestigation" id="idProSceneInvestigation"/>
        <div class="layui-form-item">
            <label class="layui-form-label">
                开始时间
            </label>
            <div class="layui-input-inline">
                <input type="text" id="beginTime" name="beginTime"
                       autocomplete="off" class="layui-input" disabled style="background-color: #b7b1b1;">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">
                结束时间
            </label>
            <div class="layui-input-inline">
                <input type="text" id="endTime" name="endTime"
                       autocomplete="off" class="layui-input" disabled style="background-color: #b7b1b1;">
            </div>
        </div>

        <div class="layui-form-item" id="difference">
            <label class="layui-form-label">
                距离结束时间天数
            </label>
            <div class="layui-input-inline">
                <input type="text" id="differenceTime" name="differenceTime"
                       autocomplete="off" class="layui-input" disabled style="background-color: #b7b1b1;">
            </div>
        </div>

        <div class="layui-form-item">
            <label for="customerName" class="layui-form-label">
                <span class="x-red">*</span>客户名称
            </label>
            <div class="layui-input-inline">
                <input type="text" id="customerName" name="customerName" lay-verify="required" placeholder="请输入"
                       autocomplete="off" class="layui-input" disabled >
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="customerName" class="layui-form-label">
                <span class="x-red">*</span>联系人
            </label>
            <div class="layui-input-inline">
                <input type="text" id="customerContacts" name="customerContacts" lay-verify="required" placeholder="请输入"
                       autocomplete="off" class="layui-input" disabled >
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="customerName" class="layui-form-label">
                <span class="x-red">*</span>联系电话
            </label>
            <div class="layui-input-inline">
                <input type="text" id="customerPhone" name="customerPhone" lay-verify="required" placeholder="请输入"
                       autocomplete="off" class="layui-input" disabled >
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="customerName" class="layui-form-label">
                <span class="x-red">*</span>供电电压
            </label>
            <div class="layui-input-inline">
                <input type="text" id="powerSupplyVoltage" name="powerSupplyVoltage" lay-verify="required" placeholder="请输入"
                       autocomplete="off" class="layui-input" >
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="customerName" class="layui-form-label">
                <span class="x-red">*</span>用电性质
            </label>
            <div class="layui-input-inline">
                <input type="text" id="electricityCharacteristic" name="electricityCharacteristic" lay-verify="required" placeholder="请输入"
                       autocomplete="off" class="layui-input" >
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="customerName" class="layui-form-label">
                <span class="x-red">*</span>负荷类别
            </label>
            <div class="layui-input-inline">
                <input type="text" id="loadType" name="loadType" lay-verify="required" placeholder="请输入"
                       autocomplete="off" class="layui-input" >
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="customerName" class="layui-form-label">
                <span class="x-red">*</span>线路敷设
            </label>
            <div class="layui-input-inline">
                <input type="text" id="lineLaying" name="lineLaying" lay-verify="required" placeholder="请输入"
                       autocomplete="off" class="layui-input" >
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="customerName" class="layui-form-label">
                <span class="x-red">*</span>申请容量
            </label>
            <div class="layui-input-inline">
                <input type="text" id="applyCapacity" name="applyCapacity" lay-verify="required" placeholder="请输入"
                       autocomplete="off" class="layui-input" >
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="customerName" class="layui-form-label">
                <span class="x-red">*</span>力率标准
            </label>
            <div class="layui-input-inline">
                <input type="text" id="forceStandard" name="forceStandard" lay-verify="required" placeholder="请输入"
                       autocomplete="off" class="layui-input" >
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="customerName" class="layui-form-label">
                <span class="x-red">*</span>用电地址
            </label>
            <div class="layui-input-inline">
                <input type="text" id="customerAddress" name="customerAddress" lay-verify="required" placeholder="请输入"
                       autocomplete="off" class="layui-input" disabled >
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="customerName" class="layui-form-label">
                <span class="x-red">*</span>经度
            </label>
            <div class="layui-input-inline">
                <input type="text" id="longitude" name="longitude"  lay-verify="number" placeholder="请输入"
                       autocomplete="off" class="layui-input" >
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="customerName" class="layui-form-label">
                <span class="x-red">*</span>纬度
            </label>
            <div class="layui-input-inline">
                <input type="text" id="latitude" name="latitude" lay-verify="number"  placeholder="请输入"
                       autocomplete="off" class="layui-input" >
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="customerName" class="layui-form-label">
                <span class="x-red">*</span>海拔高度
            </label>
            <div class="layui-input-inline">
                <input type="text" id="altitude" name="altitude" lay-verify="number"  placeholder="请输入"
                       autocomplete="off" class="layui-input" >
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="customerName" class="layui-form-label">
                <span class="x-red">*</span>现场核实容量（kW）
            </label>
            <div class="layui-input-inline">
                <input type="text" id="sceneVerificationCapacityKW" name="sceneVerificationCapacityKW"
                       lay-verify="required" placeholder="请输入"
                       autocomplete="off" class="layui-input" >
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="customerName" class="layui-form-label">
                <span class="x-red">*</span>现场审核容量（kVA）
            </label>
            <div class="layui-input-inline">
                <input type="text" id="sceneVerificationCapacitykVA" name="sceneVerificationCapacitykVA" lay-verify="required" placeholder="请输入"
                       autocomplete="off" class="layui-input" >
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="customerName" class="layui-form-label">
                <span class="x-red">*</span>现场审核总容量（千瓦视为千伏安）
            </label>
            <div class="layui-input-inline">
                <input type="text" id="sceneTotalCapacity" name="sceneTotalCapacity" lay-verify="required" placeholder="请输入"
                       autocomplete="off" class="layui-input" >
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="customerName" class="layui-form-label">
                <span class="x-red">*</span>接入点开放容量
            </label>
            <div class="layui-input-inline">
                <input type="text" id="openCapacity" name="openCapacity" lay-verify="required" placeholder="请输入"
                       autocomplete="off" class="layui-input" >
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="customerName" class="layui-form-label">
                <span class="x-red">*</span>供电方案简述
            </label>
            <div class="layui-input-inline">
                    <textarea id="content1"  name="powerSupplyScheme" style="display: none;"
                              class="layui-hide"></textarea>
            </div>
        </div>

        <div class="layui-form-item">
            <label for="customerName" class="layui-form-label">
                <span class="x-red">*</span>计量方案简述
            </label>
            <div class="layui-input-inline">
                    <textarea id="content2"  name="measurementScheme" style="display: none;"
                              class="layui-hide"></textarea>
            </div>
        </div>

        <div class="layui-form-item">
            <label for="customerName" class="layui-form-label">
                <span class="x-red">*</span>其他
            </label>
            <div class="layui-input-inline">
                <input type="text" id="other" name="other" lay-verify="required" placeholder="请输入"
                       autocomplete="off" class="layui-input" >
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>

        <div class="layui-form-item">
            <label for="customerName" class="layui-form-label">
                <span class="x-red">*</span>用电客户签字
            </label>
            <div class="layui-input-inline">
                <a><img class="layui-upload-img" src="" id="imgUrl" width="100px" /></a>
                <br><br><br>
                <input type="hidden" id="customerSign" name="customerSign"  >
                <button type="button" class="layui-btn" id="upload">
                    <i class="layui-icon">&#xe67c;</i>上传文件
                </button><script>
                updateFile("upload","imgUrl","customerSign");
            </script>
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>


        <div class="layui-form-item" id="submitButton">
            <label for="" class="layui-form-label">
            </label>
            <button  class="layui-btn" lay-filter="preservation" type=button codeTyle="1" lay-submit="">
                保存
            </button>
            <button  class="layui-btn" lay-filter="preAdd" type=button codeTyle="2" lay-submit="">
                预提交
            </button>
            <button  class="layui-btn" lay-filter="add" type=button codeTyle="3" lay-submit="">
                提交
            </button>
        </div>
		<div class="layui-form-item" id="updateStart">
            <label for="" class="layui-form-label">
            </label>
            <button  class="layui-btn" lay-filter="update" type=button codeTyle="0" lay-submit="">
                修改
            </button>
        </div>
    </form>
</div>
<script>

    var layedit = '',contentIndex1,contentIndex2;
    layui.use('layedit', function(){
        layedit = layui.layedit;
        layedit.set({
            uploadImage: {
                url: path + '/pc/upload/uploadFile' //接口url
                ,type: 'post' //默认post
            }
        });
        contentIndex1 = layedit.build("content1"); //建立编辑器
        contentIndex2 = layedit.build("content2"); //建立编辑器
    });

    layui.use(['form','layer'], function() {
        $ = layui.jquery;
        var form = layui.form
            , layer = layui.layer, layedit = layui.layedit;

        //自定义验证规则
        form.verify({});

        //监听提交
        form.on('submit(add)', function (t) {
            addSubmit(3);
        });

        //监听保存
        form.on('submit(preservation)', function (t) {
            addSubmit(1);
        });

        //监听预提交
        form.on('submit(preAdd)', function (t) {
            addSubmit(2);
        });
		
		//修改
        form.on('submit(update)', function (t) {
            addSubmit(10);
        });
    });

    function addSubmit(submitState){
        var params = {
            //tcaDescribe : layui.layedit.getContent(index),
            "idProAdmin": $("#idxProAdmin").val(),
            "idProSceneInvestigation": $("#idProSceneInvestigation").val(),
            "powerSupplyVoltage": $("#powerSupplyVoltage").val(),
            "electricityCharacteristic": $("#electricityCharacteristic").val(),
            "loadType": $("#loadType").val(),

            "lineLaying": $("#lineLaying").val(),
            "applyCapacity": $("#applyCapacity").val(),
            "forceStandard": $("#forceStandard").val(),
            "longitude": $("#longitude").val(),
            "latitude": $("#latitude").val(),
            "altitude": $("#altitude").val(),
            "sceneVerificationCapacityKw": $("#sceneVerificationCapacityKW").val(),
            "sceneVerificationCapacityKva": $("#sceneVerificationCapacitykVA").val(),
            "sceneTotalCapacity": $("#sceneTotalCapacity").val(),
            "openCapacity": $("#openCapacity").val(),
            "powerSupplyScheme": layedit.getContent(contentIndex1),
            "measurementScheme": layedit.getContent(contentIndex2),
            "other": $("#other").val(),
            "customerSign": $("#customerSign").val(),
            "submitState":submitState
        }
        if (true) {
            ajaxFun('post','/pc/project/updateSceneInvestigation',params,function(data){
                if (data.code != 0) {
                    alertFun(data);
                } else {
                    window.location.href = path + "/modules/project/onePro/xckc/list.html";
                    console.log("success !");
                }
            })
            return false;
        }
    }

    $(document).ready(function(){
        var index = 21;
        getProTime($("#idxProAdmin").val(),20);
        var params1 = {"idProAdmin":$("#idxProAdmin").val()};
        ajaxFun('get','/pc/project/getProjectBaseInfo',params1,function(data){
            if(data.code != 0){
                alertFun(data);
            }else{
                $("#customerName").val(data.data.customerName);
                $("#customerContacts").val(data.data.customerContacts);
                $("#customerPhone").val(data.data.customerPhone);
                $("#customerAddress").val(data.data.customerProvinces+""+
                    data.data.customerCities+""+data.data.customerCounties+""+data.data.customerAddress);
            }
        })
        layui.use('layedit', function() {
            layedit = layui.layedit;
            var params2 =  {"idProAdmin": $("#idxProAdmin").val()};
            ajaxFun('get','/pc/project/getSceneInvestigationInfo',params2,function(data){
                if (data.code != 0) {
                    alertFun(data);
                } else {
                    if(data.data.submitState === 3){
                        $("#submitButton").hide();
                        $("#updateStart").show();
                        $("#difference").hide();
                    } else {
                        $("#submitButton").show();
                        $("#updateStart").hide();
                    }
                    $("#idProSceneInvestigation").val(data.data.idProSceneInvestigation);
                    $("#idProSceneInvestigation").val(data.data.idProSceneInvestigation);
                    $("#powerSupplyVoltage").val(data.data.powerSupplyVoltage);
                    $("#electricityCharacteristic").val(data.data.electricityCharacteristic);
                    $("#loadType").val(data.data.loadType);
                    $("#lineLaying").val(data.data.lineLaying);
                    $("#applyCapacity").val(data.data.applyCapacity);
                    $("#forceStandard").val(data.data.forceStandard);
                    $("#longitude").val(data.data.longitude);
                    $("#latitude").val(data.data.latitude);
                    $("#altitude").val(data.data.altitude);
                    $("#sceneVerificationCapacityKW").val(data.data.sceneVerificationCapacityKw);
                    $("#sceneVerificationCapacitykVA").val(data.data.sceneVerificationCapacityKva);
                    $("#sceneTotalCapacity").val(data.data.sceneTotalCapacity);
                    $("#openCapacity").val(data.data.openCapacity);
                    $("#other").val(data.data.other);
                    $("#customerSign").val(data.data.customerSign);
                    layedit.setContent(contentIndex1,data.data.powerSupplyScheme);
                    layedit.setContent(contentIndex2,data.data.measurementScheme);

                    $("#imgUrl").attr("src",getIos(data.data.customerSignSuffixName,data.data.customerSignFilePath));
                    $("#imgUrl").parent().attr("href",data.data.customerSignFileFilePath);
                    $("#customerSign").val(data.data.customerSignFile);
                    renderForm();
                }
            })
        })
    })
</script></body></html>